package DataStructure;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Stack;

class Link
{	public int n1,n2;
	public Link(int x1,int x2)
	{	n1=x1;n2=x2;
	}
}
class Solver1671
{	int n,l,q;
	int[] Rank,Parent,Des,KeepDes;
	Link[] Lnk;
	Stack<Integer> stk=new Stack<Integer>();
	StreamTokenizer in=new StreamTokenizer(new InputStreamReader(System.in));
	
	public void Input() throws IOException
	{	int tmp1,tmp2;
		in.nextToken();n=(int)in.nval;
		in.nextToken();l=(int)in.nval;
		
		Rank=new int[n+1];Parent=new int[n+1];
		Lnk=new Link[l+1];
		for (int i=1;i<=n;i++)
		{	Parent[i]=i;Rank[i]=1;
		}	
		for (int i=1;i<=l;i++)
		{	in.nextToken();tmp1=(int)in.nval;
			in.nextToken();tmp2=(int)in.nval;
			Lnk[i]=new Link(tmp1,tmp2);
		}
		
		in.nextToken();q=(int)in.nval;
		Des=new int[q+1];Des[0]=-1;
		KeepDes=new int[q+1];
		for (int i=1;i<=q;i++)
		{	in.nextToken();Des[i]=(int)in.nval;
			KeepDes[i]=Des[i];
		}
	}
	private int FindSet(int x)
	{	if (x!=Parent[x])
			return FindSet(Parent[x]);
		return x;
	}
	private boolean MergeSet(int x,int y)
	{	int px=FindSet(x),py=FindSet(y);
		if (px!=py)
		{	if (Rank[px]>Rank[py]) Parent[py]=px;
			else Parent[px]=py;
			if (Rank[py]==Rank[px]) Rank[py]++;
			return true;
		}
		else
			return false;
	}
	public void Solve()
	{	int pieces=n,ite=1;
		Arrays.sort(Des);
		for (int i=1;i<=l;i++)
			if (i!=Des[ite])
			{	if (MergeSet(Lnk[i].n1,Lnk[i].n2))
					pieces--;
			}
			else
				ite=(ite+1)%Des.length;
		for (int i=q;i>=1;i--)
		{	int focus=KeepDes[i];
			if (MergeSet(Lnk[focus].n1,Lnk[focus].n2))
				stk.push(pieces--);
			else
				stk.push(pieces);
		}
	}
	public void Output()
	{	while (!stk.isEmpty())
			System.out.print(stk.pop() +" ");
		System.out.println();
	}
	public void main() throws IOException
	{	Input();
		Solve();
		Output();
	}
}
public class P1671
{	public static void main(String[] args) throws IOException
	{	Solver1671 solver=new Solver1671();
		solver.main();
	}
}
